package com.pansoft.androidalldemo.demo1.activity;

import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewGroup;

import com.pansoft.androidalldemo.R;
import com.pansoft.androidalldemo.viewholder.MyViewHolder;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 参见网站 http://blog.csdn.net/gdutxiaoxu/article/details/52858598
 */

public class Demo1_1 extends AppCompatActivity {

    @Bind(R.id.toolbar)
    Toolbar toolbar;
    @Bind(R.id.appbar)
    AppBarLayout appbar;
    @Bind(R.id.recyclerView)
    RecyclerView recyclerView;
  //  @Bind(R.id.fab)
    FloatingActionButton fab;
    @Bind(R.id.main_content)
    CoordinatorLayout mainContent;
    private char[] abs;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo1_1);
        ButterKnife.bind(this);
        abs = new char[26];

        for (char i = 'A'; i <='Z'; i++) {
            abs[i-'A'] = i;
        }
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setAdapter(new RecyclerView.Adapter() {
            @Override
            public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                View view = getLayoutInflater().inflate(R.layout.recycleview_item, null);
                MyViewHolder myViewHolder = new MyViewHolder(view);
                return myViewHolder;
            }

            @Override
            public void onBindViewHolder(ViewHolder holder, int position) {

                ((MyViewHolder) holder).tv.setText(abs[position]+"");
            }

            @Override
            public int getItemCount() {
                return  abs.length ;
            }
        });
    }


}
